package com.xiaomi.shop.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * @ClassName 陈欣月
 * @Descripttion
 * @Author cxy
 * @Date 2021/10/13 14:28
 * @Version 1.0
 **/
public class CharsetEncodings implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException{

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        //設置編碼格式
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");

        //工作移交
        filterChain.doFilter(request,response);//交给其他的过滤器
    }

    @Override
    public void destroy() {

    }

}
